package cn.didi.feidi.androidorder.assembly;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.os.Build;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;

import cn.didi.feidi.androidorder.R;
import cn.didi.feidi.androidorder.databinding.ViewFeiDiWaterShowBinding;
import cn.didi.feidi.androidorder.model.OrderUser;
import cn.didi.feidi.androidorder.model.ShoppingCar;

/**
 * Created by jinxiong on 2017/8/22.
 */

public class WaterShowView extends FrameLayout {


    ViewFeiDiWaterShowBinding binding;


    public WaterShowView(@NonNull Context context) {
        this(context, null);
    }

    public WaterShowView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }


    public WaterShowView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        initView(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public WaterShowView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView(context, attrs, defStyleAttr);
    }

    public void setOrUsListBean(OrderUser.OrderWaBuOrUsListBean orUsListBean) {
        binding.setWaterBucket(orUsListBean);
    }

    public void setShoppingCar(ShoppingCar shoppingCar) {
        binding.setShoppingCar(shoppingCar);
    }

    public ImageView getImageView() {
        return binding.viewFeiDiWaterShowIv;
    }

    private void initView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        binding = DataBindingUtil.inflate(inflater, R.layout.view_fei_di_water_show, this, true);
    }


}
